//
//  TestButton.m
//  XTeng
//
//  Created by 周成龙 on 16/8/15.
//  Copyright © 2016年 ZCL. All rights reserved.
//

#import "TestButton.h"

#import "VDJConstant.h"
#import "Header.h"

@interface TestButton ()

@property (nonatomic, strong)UIImageView *backImageView;
@property (nonatomic, strong)UILabel *textLabel;

@end

@implementation TestButton

- (void)setType:(TestButtonType)type
{
    switch (type) {
        case TestButtonTypeNone:{
            self.textLabel = nil;
            self.backImageView.image = [UIImage imageNamed:@"考试"];
        }
            break;
            
        case TestButtonTypeCountDown:{
            self.backImageView = nil;
            self.textLabel.text = [NSString stringWithFormat:@"还剩\n2天"];
            self.backgroundColor = kGetColor(199, 88, 33);
        }
            break;
            
        case TestButtonTypeToday:{
            self.backImageView = nil;
            self.textLabel.text = [NSString stringWithFormat:@"今天\n考试"];
            self.backgroundColor = kGetColor(219, 45, 57);
        }
            break;
            
        case TestButtonTypeEnd:{
            self.backImageView = nil;
            self.textLabel.text = [NSString stringWithFormat:@"已结束"];
            self.backgroundColor = kGetColor(149, 149, 149);
        }
            break;
            
        default:{
            self.backImageView = nil;
            self.textLabel = nil;
        }
            break;
    }
}

- (UILabel *)textLabel
{
    if (nil == _textLabel) {
        _textLabel = [UILabel labelWithFont:20 withTextColor:kWhiteColor withBackgroundColor:kClearClolor withTextAlignment:NSTextAlignmentCenter withText:@"" withNumberLines:2];
        _textLabel.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
        [self addSubview:_textLabel];
    }
    return _textLabel;
}

- (UIImageView *)backImageView
{
    if (nil == _backImageView) {
        _backImageView = [[UIImageView alloc] init];
        _backImageView.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
        [self addSubview:_backImageView];
    }
    return _backImageView;
}

@end
